
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>鹰眼短链后台管理中心</title>
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="robots" content="noindex,nofollow">
    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->
    <link href="/static/admin/assets/themes/admin/bootstrap.min.css" rel="stylesheet">
    <link href="/static/admin/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/static/admin/assets/themes/admin/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        if (window.parent !== window.self) {
            document.write              = '';
            window.parent.location.href = window.self.location.href;
            setTimeout(function () {
                document.body.innerHTML = '';
            }, 0);
        }
    </script>
    <style type="text/css">
        .captcha-img {
            cursor: pointer;
            position:absolute;
            right:1px;
            top:1px;
        }
    </style>
</head>
<body>
<div class="wrap">
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <h1 class="text-center">鹰眼短链后台管理中心</h1>
                <form class="js-ajax-form" method="post">
                    <div class="form-group">
                        <input type="text" id="input_username" name="username" class="form-control"
                               autocomplete="new-username"
                               placeholder="请输入用户名">
                    </div>

                    <div class="form-group">
                        <input type="password" id="input_password" name="password" class="form-control"
                               autocomplete="new-password"
                               placeholder="请输入密码">
                    </div>

                    <div class="form-group">
                        <div style="position: relative;">
                            <input type="text" name="captcha" placeholder="验证码" class="form-control captcha">
                            <img src="{:captcha_src('login')}"  title="换一张" class="captcha-img"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="tips_error"></div>
                    </div>
                    <div class="form-group">
                        {:token()}
                        <button class="btn btn-primary btn-block js-ajax-submit" type="submit" style="margin-left: 0px"
                                data-loadingmsg="正在加载...">
                            登录                        </button>
                    </div>

                </form>
            </div>
        </div>

    </div>
</div>
<script src="/static/admin/assets/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer/layer.js"></script>
<script>
    $(function(){
        $(".captcha-img").click(function () {
            $(".captcha-img").attr("src", "{:captcha_src('login')}");
        });

        $('.js-ajax-form').submit(function () {
            var data  ={
                username : $('input[name=username]').val(),
                password : $('input[name=password]').val(),
                captcha : $('input[name=captcha]').val()
            };
            if(!data.username){
                $('.tips_error').html('用户名不能为空');
                return false;
            }
            if(!data.password){
                $('.tips_error').html('密码不能为空');
                return false;
            }
            $.ajax({
                url: "{:url('User/doLogin')}",
                type: "POST",
                contentType: "application/x-www-form-urlencoded",
                data: $('.js-ajax-form').serialize(),
                dataType: 'json',
                async: false,
                success: function (res) {
                    if(res.errorCode === 200){
                        $('.tips_error').html(res.message);
                        window.location.href = res.data.url;
                    }else{
                        layer.alert(res.message, {
                            title: '提示',
                            icon: 2
                        });
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>
